Function.prototype.myCall = function (context, ...args) {
    context = context || window;// 如果没有传入context，则默认为window
    const key = Symbol('fn');
    context[key] = this;
    const result = context[key](...args);
    delete context[key];
    return result;
}

Function.prototype.myApply = function (context, args) {
    context = context || window;
    const key = Symbol('fn');
    context[key] = this;
    let result;
    if (args && Array.isArray(args)) {
        result = context[key](...args);
    } else {
        result = context[key]()
    }
    delete context[key];
    return result;
}

Function.prototype.myBind = function (context, ...args) {
    return function fn (...innerArgs) {
        return this.apply(context, [...args, ...innerArgs])
    }
}

const call1 = function (context, ...args) {
    context = context || window;
    const key = Symbol('fn');
    context[key] = this;
    const result = context[key](...args);
    delete context[key];
    return result;
}
const apply1 = function (context, args) {
    context = context || window;
    const key = Symbol('fn');
    context[key] = this;
    let result;
    if (args && Array.isArray(args)) {
        result = context[key](...args)
    } else {
        result = context[key]()
    }
    delete context[key];
    return result;

}
const bind1 = function (context, ...args) {
    return function (...innerArgs) {
        return this.apply(context, [...args, ...innerArgs])
    }
}